feat: Add asset selector dropdown#192
Conversation
|
@EmmyKay0026 is attempting to deploy a commit to the ritik4ever's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@EmmyKay0026 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
📝 WalkthroughWalkthroughThe pull request introduces a new backend configuration endpoint that exposes an allowed assets list, which the frontend fetches on component mount to dynamically populate an asset selector dropdown. The asset input conditionally renders as a dropdown when configuration loads successfully, or falls back to a text input if the fetch fails. Changes
Sequence DiagramsequenceDiagram
participant Component as CreateStreamForm
participant Service as getConfig()
participant Backend as GET /api/config
participant State as Component State
Component->>Component: Component mounts
Component->>Service: Call getConfig()
Service->>Backend: HTTP GET /api/config
Backend-->>Service: {allowedAssets: string[]}
Service-->>Component: AppConfig returned
Component->>State: Store allowedAssets
Component->>Component: Validate current assetCode
alt assetCode not in allowedAssets
Component->>State: Update assetCode to USDC or first asset
end
Component->>Component: Re-render with dropdown
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@frontend/src/components/CreateStreamForm.tsx`:
- Around line 124-147: The effect's fetchConfig closure captures a stale
values.assetCode and can overwrite a user's in-flight edit; modify the
useEffect/fetchConfig flow to add a cancellation flag and a configLoading state,
call getConfig() then setAllowedAssets only if not cancelled, read the current
assetCode from the latest state (not the captured values) before applying
defaulting, and only call setValues to default the asset when the current value
is invalid and the request isn't cancelled; also ensure you set configLoading
false and avoid setConfigFetchFailed or any state updates after
unmount/cancellation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e63f6c98-97f8-44a1-a861-657f85fa1992
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
backend/src/index.tsfrontend/src/components/CreateStreamForm.tsxfrontend/src/services/api.ts
closes #162
Overview
This PR improves the user experience by replacing the free-text assetCode input in the CreateStreamForm with a dynamic dropdown. The list of available assets is now fetched directly from the backend configuration, ensuring that users can only select assets currently supported by the platform.
Changes
Backend
Frontend
Added getConfig function to the API service layer.
Updated CreateStreamForm to: